In this script, there is conducted the estimation for the measure_marginal approach for a single given env. The programs is the set of bytecode programs with varying number of opcodes. The measurements are time measurements of program runs or benchmarks. The estimation of each opcode is calculated as the regression against the number of a given opcode in the executed programs.

Parametrization. The evm client name env=ethereumjs, the file with programs programs=pg_marginal_full_step5_v2.csv, the file with measurements results=results_marginal_full_ethereumjs.csv,
the output csv file with estimated cost output_estimated_cost=reports/estimated_cost_ethereumjs_full.csv, should the details be included in the report details=FALSE.

The comparision of result. Before and after removing outlying measurement. Switch removed_outliers to FALSE to see the comparison.

if (removed_outliers) {
  measurements = remove_compare_outliers(measurements, 'measure_total_time_ns', c(env))
}

Now we can investigate the linear regressions.

for (opcode in all_opcodes) {
  estimate = compute_all(opcode=opcode, env=env, use_median=TRUE, plots=ifelse(details,'all','scatter'))
  estimates[nrow(estimates) + 1, ] = c(opcode, estimate, env)
}

The resulting estimates based on the regressions above.

estimates
##                 op estimate_marginal_ns estimate_marginal_ns_stderr        env
## 1              ADD            132.26805                   27.835221 ethereumjs
## 2              MUL            199.72199                   14.704672 ethereumjs
## 3              SUB            178.94124                   36.785821 ethereumjs
## 4              DIV            269.20875                   31.352829 ethereumjs
## 5             SDIV            227.80067                   16.882264 ethereumjs
## 6              MOD            192.20779                   15.309089 ethereumjs
## 7             SMOD            258.44221                   18.863275 ethereumjs
## 8           ADDMOD            263.74307                   23.691108 ethereumjs
## 9           MULMOD            231.62043                   19.515207 ethereumjs
## 10             EXP            673.70590                   18.986059 ethereumjs
## 11      SIGNEXTEND            350.47239                   28.207785 ethereumjs
## 12              LT             97.07694                   25.360768 ethereumjs
## 13              GT             86.52696                   29.685816 ethereumjs
## 14             SLT            157.21070                   26.837513 ethereumjs
## 15             SGT            198.11116                   18.231367 ethereumjs
## 16              EQ            122.82860                   19.877711 ethereumjs
## 17          ISZERO            153.64723                   25.844119 ethereumjs
## 18             AND            164.26466                   27.618169 ethereumjs
## 19              OR            185.28692                   27.158801 ethereumjs
## 20             XOR            183.11746                   16.268559 ethereumjs
## 21             NOT            197.41416                   27.662073 ethereumjs
## 22            BYTE            278.91065                   21.336714 ethereumjs
## 23             SHL            225.87825                   16.820664 ethereumjs
## 24             SHR            154.58143                   18.055277 ethereumjs
## 25             SAR            262.10916                   20.084774 ethereumjs
## 26       KECCAK256           6353.65402                   35.528083 ethereumjs
## 27         ADDRESS            457.18261                   12.815773 ethereumjs
## 28          ORIGIN            466.13101                   11.668656 ethereumjs
## 29          CALLER            449.58937                   13.003018 ethereumjs
## 30       CALLVALUE            189.16048                    7.946375 ethereumjs
## 31    CALLDATALOAD            228.45539                   31.374865 ethereumjs
## 32    CALLDATASIZE            204.26274                    7.798457 ethereumjs
## 33    CALLDATACOPY           1000.49365                   24.030018 ethereumjs
## 34        CODESIZE            142.20692                   10.746361 ethereumjs
## 35        CODECOPY            669.66808                   18.038823 ethereumjs
## 36        GASPRICE            113.56229                   10.982009 ethereumjs
## 37     EXTCODESIZE           1169.14168                  260.989564 ethereumjs
## 38     EXTCODECOPY            968.62193                  355.525577 ethereumjs
## 39  RETURNDATASIZE            218.79456                    8.063747 ethereumjs
## 40  RETURNDATACOPY            803.04638                   10.767151 ethereumjs
## 41     EXTCODEHASH           1346.27000                  210.389749 ethereumjs
## 42        COINBASE            575.03213                   18.691956 ethereumjs
## 43       TIMESTAMP            211.41542                    8.865074 ethereumjs
## 44          NUMBER            209.45448                    4.370945 ethereumjs
## 45      DIFFICULTY            653.18114                    9.396715 ethereumjs
## 46        GASLIMIT            209.33806                   12.061768 ethereumjs
## 47         CHAINID            163.60458                    8.251324 ethereumjs
## 48     SELFBALANCE            123.71643                    8.026308 ethereumjs
## 49             POP             81.18471                   15.760555 ethereumjs
## 50           MLOAD            928.48668                   18.448041 ethereumjs
## 51         MSTORE8            602.45871                   23.637567 ethereumjs
## 52            JUMP            229.73362                   16.173801 ethereumjs
## 53           JUMPI            328.47637                  106.874301 ethereumjs
## 54              PC            150.61996                   11.273768 ethereumjs
## 55           MSIZE            134.30760                    5.413652 ethereumjs
## 56             GAS            126.35415                    7.848459 ethereumjs
## 57        JUMPDEST            143.98632                    3.298388 ethereumjs
## 58           PUSH0            133.44249                   10.732106 ethereumjs
## 59            LOG0            721.27495                   15.799077 ethereumjs
## 60            LOG1           2467.10034                   45.270110 ethereumjs
## 61            LOG2           3988.44295                   77.818945 ethereumjs
## 62            LOG3           4451.21617                  367.177979 ethereumjs
## 63            LOG4           4489.84915                  593.268648 ethereumjs
## 64            CALL          93963.38824                 6800.120547 ethereumjs
## 65          RETURN            384.86442                  213.812305 ethereumjs
## 66    DELEGATECALL          91920.51446                 6979.294371 ethereumjs
## 67      STATICCALL          94003.66329                 7296.490573 ethereumjs
## 68          REVERT            320.08106                  273.931229 ethereumjs
## 69           PUSH1            242.03742                    9.044858 ethereumjs
## 70           PUSH2            264.49816                    6.549269 ethereumjs
## 71           PUSH3            342.12334                    8.992611 ethereumjs
## 72           PUSH4            339.92432                    9.461127 ethereumjs
## 73           PUSH5            363.99631                    8.595119 ethereumjs
## 74           PUSH6            394.84733                   13.950138 ethereumjs
## 75           PUSH7            387.90798                    7.919046 ethereumjs
## 76           PUSH8            389.55106                    7.936583 ethereumjs
## 77           PUSH9            417.54304                    8.808413 ethereumjs
## 78          PUSH10            431.81931                    6.935119 ethereumjs
## 79          PUSH11            449.27850                    7.977033 ethereumjs
## 80          PUSH12            455.69796                    9.830130 ethereumjs
## 81          PUSH13            479.73673                   14.548979 ethereumjs
## 82          PUSH14            475.94167                   10.044055 ethereumjs
## 83          PUSH15            493.77095                   10.573443 ethereumjs
## 84          PUSH16            540.90117                    8.427299 ethereumjs
## 85          PUSH17            528.34991                    7.263718 ethereumjs
## 86          PUSH18            544.43726                    6.850887 ethereumjs
## 87          PUSH19            546.16531                    7.661045 ethereumjs
## 88          PUSH20            555.42124                    9.806170 ethereumjs
## 89          PUSH21            577.37607                    8.722418 ethereumjs
## 90          PUSH22            596.55415                   10.174789 ethereumjs
## 91          PUSH23            596.04149                   15.267580 ethereumjs
## 92          PUSH24            621.65577                    9.339925 ethereumjs
## 93          PUSH25            614.67813                   12.870584 ethereumjs
## 94          PUSH26            638.09163                   15.668432 ethereumjs
## 95          PUSH27            667.82544                   14.375130 ethereumjs
## 96          PUSH28            667.13297                   11.558033 ethereumjs
## 97          PUSH29            655.08285                    7.802473 ethereumjs
## 98          PUSH30            685.02071                    9.429147 ethereumjs
## 99          PUSH31            702.93889                    9.179742 ethereumjs
## 100         PUSH32            732.00859                   10.631730 ethereumjs
## 101           DUP1            118.17128                    7.497442 ethereumjs
## 102           DUP2            133.78932                   13.613640 ethereumjs
## 103           DUP3            180.85868                   16.976503 ethereumjs
## 104           DUP4            134.73052                   12.887440 ethereumjs
## 105           DUP5            173.45270                   23.473109 ethereumjs
## 106           DUP6            144.49677                   18.068449 ethereumjs
## 107           DUP7            149.64431                   17.051710 ethereumjs
## 108           DUP8            163.48825                   14.350890 ethereumjs
## 109           DUP9            141.13826                   18.056604 ethereumjs
## 110          DUP10            150.25064                   30.812093 ethereumjs
## 111          DUP11            136.07454                   27.510872 ethereumjs
## 112          DUP12            172.41247                   14.294766 ethereumjs
## 113          DUP13            141.17858                   26.005035 ethereumjs
## 114          DUP14            140.81505                   16.879263 ethereumjs
## 115          DUP15            131.81189                   21.368839 ethereumjs
## 116          DUP16            139.16962                   17.359573 ethereumjs
## 117          SWAP1            103.53924                   16.343656 ethereumjs
## 118          SWAP2            100.98125                   21.756797 ethereumjs
## 119          SWAP3            102.86998                   16.230710 ethereumjs
## 120          SWAP4             99.06179                   16.684112 ethereumjs
## 121          SWAP5            119.90718                   22.884600 ethereumjs
## 122          SWAP6             98.00344                   19.648819 ethereumjs
## 123          SWAP7            105.11945                   17.188423 ethereumjs
## 124          SWAP8             84.70964                   14.085465 ethereumjs
## 125          SWAP9            117.05235                   18.808799 ethereumjs
## 126         SWAP10            113.01101                   12.051088 ethereumjs
## 127         SWAP11            121.42732                   21.867750 ethereumjs
## 128         SWAP12             85.52003                   24.685725 ethereumjs
## 129         SWAP13            140.34054                   12.929876 ethereumjs
## 130         SWAP14            109.31540                   19.513297 ethereumjs
## 131         SWAP15            122.21964                   20.933705 ethereumjs
## 132         SWAP16            122.22117                   26.348528 ethereumjs

The results are exported to reports/estimated_cost_ethereumjs_full.csv.